﻿using System;
using System.IO;

using Microsoft.WowAddonStudio.Lua.Model;

namespace Microsoft.WowAddonStudio.Lua.Loaders
{
    public abstract class FileDocumentationLoader
    {
        /// <summary>
        /// Loads the documentation from a file.
        /// </summary>
        /// <param name="fileStream">A <see cref="Stream"/> to the file.</param>
        /// <returns>An instance of the <see cref="DocumentationScope"/> class.</returns>
        public abstract DocumentationScope LoadFileDocumentation(Stream fileStream);

        /// <summary>
        /// Loads the documentation from a file.
        /// </summary>
        /// <param name="path">The path of the file.</param>
        /// <returns>An instance of the <see cref="DocumentationScope"/> class.</returns>
        public DocumentationScope LoadFileDocumentation(string path)
        {
            if (path == null)
                throw new ArgumentNullException("path");

            using (var stream = File.Open(path, FileMode.Open, FileAccess.Read))
            {
                return this.LoadFileDocumentation(stream);
            }
        }
    }
}
